import { EntityModel } from '@midwayjs/orm';
import {
  Column,
  CreateDateColumn,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@EntityModel('inventory') // 可以指定表名，不指定会根据类名自己生成
export class Inventory {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  product_code: string = null;

  @Column({
    nullable: true,
  })
  weight: string;

  @Column({
    nullable: false,
    type: 'decimal',
    precision: 20,
    scale: 10,
  })
  buying_price: number;

  @Column({
    nullable: false,
    type: 'decimal',
    precision: 20,
    scale: 10,
  })
  payment_amount: number;

  @Column({
    nullable: false,
  })
  box_gauge: number;

  @Column({
    nullable: false,
  })
  product_quantity: number;

  @Column({
    nullable: false,
  })
  brand_side: string;

  @Column({
    nullable: false,
  })
  supplier: string;

  @Column({
    nullable: true,
  })
  whether_to_rebate: number;

  @Column({
    nullable: false,
  })
  warehousing_time: string;

  @Column({
    nullable: false,
  })
  remaining_inventory_quantity: number;

  @Column({
    nullable: true,
    type: 'decimal',
    precision: 20,
    scale: 10,
  })
  rebate_rate: number;

  @Column({
    nullable: true,
    type: 'decimal',
    precision: 20,
    scale: 10,
  })
  rebate: number;

  @Column({
    nullable: true,
  })
  cost_params: string;

  @Column({
    nullable: false,
    type: 'decimal',
    precision: 20,
    scale: 10,
  })
  cost: number;

  @Column({
    nullable: true,
  })
  source: number;

  @Column({
    nullable: false,
    type: 'decimal',
    precision: 20,
    scale: 10,
  })
  unit_price: number;

  @CreateDateColumn({ comment: '创建时间', type: 'timestamp' })
  created_at: Date;

  @UpdateDateColumn({ comment: '更新时间', type: 'timestamp' })
  updated_at: Date;
}
